package com.jdbc.conn;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.IOException;
import java.sql.Connection;
import java.util.Properties;

/**
 * @author wzm
 * @create 2023-04-07 14:02
 */
public class Conn03 {
    public static void main(String[] args) throws Exception {

        //1.创建properties
        Properties properties = new Properties();

        //2.从配置文件中读取流
        properties.load(Conn03.class.getClassLoader().getResourceAsStream("druid.properties"));

        //3.获取数据源
        DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);
        //4.获取数据库连接
        Connection connection = dataSource.getConnection();
        System.out.println(connection);

    }
}
